﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Excel = Microsoft.Office.Interop.Excel;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Windows.Forms;
using System.IO;

namespace GeneralLibs
{
    public class SortDataAlphabetic
    {
        //SortData in DataTable
        static public DataTable DataTableSort(DataTable dtTable, string sortColumn, int sortOrder)
        {
            DataSet dsSorted = new DataSet();
            string columnKey = sortColumn;
            string sortDirection = "";
            string sortFormat = "{0} {1}";
            switch (sortOrder)
            {
                case 0:
                    sortDirection = "ASC";
                    break;
                case 1:
                    sortDirection = "DESC";
                    break;
                default:
                    sortDirection = "ASC";
                    break;
            }

            dtTable.DefaultView.Sort = string.Format(sortFormat, columnKey, sortDirection);
            return dtTable.DefaultView.Table;
        }
    }
}
